package com.css.zfzx.fwsjcj.modules.basecontroller.service.impl;

import com.css.bpm.platform.org.division.repository.DivisionRepository;
import com.css.zfzx.fwsjcj.modules.basecontroller.service.FwDivisionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Iterator;
import java.util.List;

@Service
public class FwDivisionServiceImpl implements FwDivisionService {

    @Autowired
    DivisionRepository baseRepository;

    @Override
    public String findFullNameById(String divisionId) {
        String allParentId = baseRepository.findAllParentIdByDivisionId(divisionId);

        StringBuilder fullName = new StringBuilder();
        if (allParentId != null && !"".equals(allParentId)) {
            String[] ids = allParentId.split(",");
            List<String> names = baseRepository.findDivisionNamesByDivisionId(ids);

            String name;
            for (Iterator var6 = names.iterator(); var6.hasNext(); fullName = fullName.append(name)) {
                name = (String) var6.next();
            }
        }
        String full=fullName.toString();
        String address=full.replace("中华人民共和国","");
        return address;
    }
}
